package com.geekaca.d09;

import java.io.*;

public class TestCopyIso {


    public static void main(String[] args) {
        File file = new File("\\\\10.10.10.118\\wd_disk\\vmpc iso\\windows_me.iso");
        // 复制到 当前路径
        OutputStream fos = null;
        InputStream fis = null;
        try {
            fis = new FileInputStream(file);
            fos = new FileOutputStream("C:\\temp\\windows_me.iso");
            byte[] buffer = new byte[16384];
            int length;
            // todo: 统计搬运了多少次?
            int count = 0;
            while ((length = fis.read(buffer)) != -1) {
                fos.write(buffer, 0, length);
                count += 1;
            }
            System.out.println("一共搬运了" + count + "次");
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (fis != null) {
//                fos.flush();
                try {
                    fos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (fos != null) {
                try {
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }


    }
}


